﻿using System;
using System.Windows;
using System.Windows.Markup;
using MaxStoreErp.Core.Security;

namespace MaxStoreErp.Core.Extensions
{
    public class AdminAccessUiExtension : MarkupExtension
    {
        public bool IsAdminAccess { get; set; }

        public AdminAccessUiExtension()
            : this(true)
        {

        }

        public AdminAccessUiExtension(bool isAdminAccess)
        {
            IsAdminAccess = isAdminAccess;
        }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            if (IsAdminAccess && PermissionHelper.IsAdmin())
                return Visibility.Visible;

            return !IsAdminAccess ? Visibility.Visible : Visibility.Collapsed;
        }
    }
}
